var Workport = Workport || {};
//@Path("/Tag")
Workport.ExpertsAPI = (function(){
	
	var root = WP_RESTFUL_URL + (WP_RESTFUL_URL.endsWith('/') ? '' : '/');
	
	var urls = ["Experts"];
	
	function getUrl(/*index, replace1, replace2, ...*/) {
		var index, i, loops, r;
		loops = arguments.length;
		if (loops > 0) {
			index = arguments[0];
			r = root + urls[index];
			for (i = 1; i < loops; i++)
				r = r.replace("{"+i+"}", arguments[i]);
		}
		return r;
	}
	
	function sendGetRequest(url,callback,query,sync){
		if(sync){
			return sfw.Http.syncGet(url,callback,query);
		} else {
			return sfw.Http.get(url,callback,query);
		}
	}
	
	return {
		// @GET	@Path("/Experts")
		// public TagResponse GetAllExperts()
		getExperts:function(handler,request){
			return sendGetRequest(getUrl(0),function(xhr,data){
				if (!sfw.Http.handleError(xhr, data)) {
					if(jQuery.isFunction(handler)){
						handler(toViewModel(data));
					}
				}
			},{
				tags:request.tag,
				ps:request.ps,
				pn:request.pn
			},request.sync);
			function toViewModel(data){
				return data;
			}
		}
	}
})();
